<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Flower Shop - Giỏ Hàng</title>
        <link rel="stylesheet" type="text/css" href="<?php echo asset_url() . 'css/style.css'; ?>" />
        <link rel="stylesheet" type="text/css" href="<?php echo asset_url() . 'css/stylenav.css'; ?>" />
        <script type="text/javascript" src="<?php echo asset_url() . 'js/jquery.js'; ?>"></script>
        <script>
            $(document).ready(function() {

                $('#ck').change(function() {
                    if ($(this).is(":checked")) {
                        $('#name_receiver').val($('#name_sender').val());
                        $('#phone_receiver').val($('#phone_sender').val());
                        $('#address_receiver').val($('#address_sender').val());
                    }
                    else
                    {
                        $('#name_receiver').val("");
                        $('#phone_receiver').val("");
                        $('#address_receiver').val("");
                    }
                    // $('#textbox1').val($(this).is(':checked'));
                });

//                $(".qty").change(function() {
////                    //Get the id of this clicked item
////
////                    pos = $(this).val();
////
////                    alert(pos);
//                    $(".qty").each(element){
//                       
//                    }
//
//                });

            });
        </script>

        <script>
            function book_suggestion()
            {
                // var sl = document.getElementById("SoLuong").value;
                var sl = $(this).attr('id');
                alert(sl);
                // var MaHoa = document.getElementById("MaHoa").value;
//                var xhr;
//                if (window.XMLHttpRequest) { // Mozilla, Safari, ...
//                    xhr = new XMLHttpRequest();
//                } else if (window.ActiveXObject) { // IE 8 and older
//                    xhr = new ActiveXObject("Microsoft.XMLHTTP");
//                }
//                var data = "sl=" +sl+"&MaHoa="+MaHoa;
//                xhr.open("POST", "http://localhost:8080/flowershop-424-641/index.php/ajax", true);
//                xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
//                xhr.send(data);
//                xhr.onreadystatechange = display_data;
//                function display_data() {
//                    if (xhr.readyState === 4) {
//                        if (xhr.status === 200) {
//                            if (xhr.responseText !== 'ok')
//                            {
//                                alert(xhr.responseText);
//                            }
//                            //document.getElementById("suggestion").innerHTML = xhr.responseText;
//                        } else {
//                            alert('There was a problem with the request.');
//                        }
//                    }
//                }
            }
        </script>
    </head>
    <body>
        <div id="wrap">
            <?php
            include '/layout/header.php';
            ?>
            <?php echo form_open('shopping/check_out') ?>
            <div class="center_content" style="background:white;margin-top: 5px;">
                <div class="top_content">
                    <?php
                    if ($this->cart->contents() == null) {
                        header("location: http://localhost:8080/flowershop-424-641/index.php/category");
                    } else {
                        $cart = $this->cart->contents();
                        ?>
                        <div id="cart">
                            <table id="tb" style="border-color:#99CC33;width: 100%;border-radius: 3px;-webkit-border-radius: 3px;-moz-border-radius: 3px;font-size: 12px">
                                <thead>
                                    <tr>
                                        <th>Tên Sản Phẩm</th>
                                        <th>Hình Ảnh</th>
                                        <th>Đơn Giá</th>
                                        <th>Số Lượng</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <?php foreach ($cart as $item): ?>
                                    <tbody style="font-size: 15px;font-weight: bold;">
                                        <tr>
                                            <td><?php echo $item['name']; ?></td>
                                            <td><img height="50 px" src="<?php echo asset_url() . $item['options']['HinhAnh']; ?>" alt="" class="thumb" border="0" /></td>
                                            <td><?php echo $item['subtotal']; ?></td>
                                            <td width="150px"><form><input size="7px" class="qty" name="SoLuong" id="SoLuong<?php echo $item['id']; ?>" onchange ="javascript:myplugin(this)" type="text" value="1"/><input type="submit" value="Thay Đổi"/></form></td>
                                            <td class="remove">
                                                <?php echo anchor('shopping/remove/' . $item['rowid'], 'Bỏ ra'); ?>
                                            </td>
                                        </tr>
                                    </tbody>
                                <?php endforeach; ?>
                                <tfoot style="background-color: #99CC33;vertical-align: middle;border-color:#99CC33;font-size: 15px;font-weight: bold;">
                                    <tr class="total">
                                        <td align="left" valign="middle" colspan="3">
                                            <a id="backlink" style="font-size: 13px" href="http://localhost:8080/flowershop-424-641/index.php/category">Tiếp tục mua hàng</a>
                                        </td>
                                        <!--<td  align="left" valign="middle" colspan="2"><strong>Total: </strong><?php// echo $this->cart->total(); ?> </td>-->
                                    </tr>
                                </tfoot>
                            </table>
                        </div>
                    <?php } ?>
                </div>            
                <div class="clear"></div>
                <div class="bot_content">
                    <div class="thongtinlienlac">
                        <label class="tle">Thông Tin Liên Lạc</label>
                        <table width="100%">
                            <tr style="background: white">
                                <td>Email của bạn:</td>
                                <td><input name="id_user" id="id_user" type="hidden" value="<?php echo $this->session->userdata("MaNguoiDung"); ?>"><input name="email_sender" type="text" value="<?php echo $this->session->userdata("Email"); ?>" style="width: 200px"/> </td>

                            </tr> 
                            <tr style="background: white">
                                <td>Họ và tên:</td>
                                <td><input name="name_sender" id="name_sender" type="text" value="<?php echo $this->session->userdata("HoTen"); ?>" style="width: 200px"/> </td>
                            </tr> 
                            <tr style="background: white">
                                <td>Điện thoại:</td>
                                <td><input name="phone_sender" id="phone_sender" type="text" value="<?php echo $this->session->userdata("SDT"); ?>" style="width: 200px"/> </td>
                            </tr> 
                            <tr style="background: white">
                                <td>Địa chỉ:</td>
                                <td><input name="address_sender" id="address_sender" type="text" value="<?php echo $this->session->userdata("DiaChi"); ?>" style="width: 200px"/> </td>
                            </tr> 
                        </table>
                    </div>
                    <div class="thongtinlienlac" style="float: right;">
                        <label class="tle">Thông Tin Người Nhận</label>
                        <table width="100%">                        
                            <tr style="background: white">
                                <td>Họ và tên:</td>
                                <td><input name="name_receiver" id="name_receiver" type="text" style="width: 200px"/> </td>
                            </tr> 
                            <tr style="background: white">
                                <td>Điện thoại:</td>
                                <td><input name="phone_receiver" id="phone_receiver" type="text" style="width: 200px"/> </td>
                            </tr> 
                            <tr style="background: white">
                                <td>Địa chỉ:</td>
                                <td><input name="address_receiver" id="address_receiver" type="text" style="width: 200px"/> </td>
                            </tr> 
                            <tr style="background: white">
                                <td>Ngày Giao:</td>
                                <td><input name="date_receive" type="date" value="<?php echo date('Y-m-d'); ?>" style="width: 200px"/> </td>
                            </tr> 
                        </table>
                    </div>  
                    <div class="thongtinlienlac" style="margin-left: 25%"> 
                        <br>
                        <input type="checkbox" name="ck" id="ck">Người Gửi Là Người Nhận<br>
                        <br>

                        <button type="submit" onclick="X();" style="margin-left: 30%" class="checkout">Xác Nhận Mua Hàng</button>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
            <?php echo form_close(); ?>
            <div class="footer">
                <div class="left_footer"><?php echo img(asset_url() . 'imgs/footer_logo.gif', TRUE); ?><br />
                    <a href="http://csscreme.com"><?php echo img(asset_url() . 'imgs/csscreme.gif', TRUE); ?></a></div>
                <div class="right_footer"> <a href="http://all-free-download.com/free-website-templates/">home</a> <a href="http://all-free-download.com/free-website-templates/">about us</a> <a href="http://all-free-download.com/free-website-templates/">services</a> <a href="http://all-free-download.com/free-website-templates/">privacy policy</a> <a href="http://all-free-download.com/free-website-templates/">contact us</a> </div>
            </div>
    </body>
</html>
